/*
 * @Description: 钱包账户
 * @Author: iamsmiling
 * @Date: 2021-05-30 13:17:42
 * @LastEditTime: 2021-06-13 11:28:11
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/domain/remote/bill/bill_entity.dart';
import 'package:credit_business_circle/pages/mine/children/wallet/wallet_controller.dart';
import 'package:credit_business_circle/routes/app_routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class WalletPage extends GetView<WalletController> {
  const WalletPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("钱包账户"),
          elevation: 0,
          actions: [
            TextButton(
                onPressed: () =>
                    Get.toNamed(AppRoutes.mine + AppRoutes.propkit),
                child: Text("我的道具"))
          ],
        ),
        body: Column(
          children: [
            Container(
              width: R.dimen.width,
              padding: EdgeInsets.only(
                  left: R.dimen.dp20, bottom: R.dimen.dp45, top: R.dimen.dp30),
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage(
                        R.image.walletBg,
                      ),
                      fit: BoxFit.cover)),
              margin: EdgeInsets.only(
                top: R.dimen.dp20,
                bottom: R.dimen.dp10,
                left: R.dimen.dp15,
                right: R.dimen.dp15,
              ),
              child: Row(
                children: [
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        margin: EdgeInsets.only(bottom: R.dimen.dp22),
                        child: Text(
                          "账户余额",
                          style: TextStyle(
                              color: R.color.ffffffff, fontSize: R.dimen.sp12),
                        ),
                      ),
                      // Row(
                      //   children: [
                      //     Text("88.88",
                      //         style: TextStyle(
                      //             fontSize: R.dimen.sp34,
                      //             fontWeight: FontWeight.w600,
                      //             color: R.color.ffffffff))
                      //   ],
                      // ),
                      Text.rich(TextSpan(
                          text: "¥",
                          style: TextStyle(
                              fontSize: R.dimen.sp12,
                              fontWeight: FontWeight.w600,
                              color: R.color.ffffffff),
                          children: [
                            TextSpan(
                                text: "88.88",
                                style: TextStyle(
                                    fontSize: R.dimen.sp34,
                                    fontWeight: FontWeight.w600,
                                    color: R.color.ffffffff))
                          ]))
                    ],
                  ),
                  Spacer(),
                  GestureDetector(
                    onTap: () =>
                        Get.toNamed(Get.currentRoute + AppRoutes.recharge),
                    child: Container(
                      margin: EdgeInsets.only(
                          right: R.dimen.dp28, top: R.dimen.dp15),
                      child: Text(
                        "充值",
                        style: TextStyle(
                            color: R.color.ff096c4f,
                            fontSize: R.dimen.sp18,
                            fontWeight: FontWeight.w600),
                      ),
                    ),
                  )
                ],
              ),
            ),
            Expanded(
              child: ListView.builder(
                  shrinkWrap: true,
                  padding: EdgeInsets.symmetric(horizontal: R.dimen.dp15),
                  itemCount: controller.bills.length,
                  itemBuilder: (BuildContext context, int i) {
                    BillEntity item = controller.bills[i];
                    return Container(
                      margin: EdgeInsets.only(top: R.dimen.dp16),
                      decoration: BoxDecoration(
                          border: Border(
                              bottom: BorderSide(
                                  width: .5, color: R.color.ffdddddd))),
                      child: Row(
                        children: [
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                item.label,
                                style: TextStyle(
                                    fontWeight: FontWeight.w600,
                                    fontSize: R.dimen.sp14,
                                    color: R.color.ff333333),
                              ),
                              Container(
                                  margin: EdgeInsets.only(
                                      top: R.dimen.dp12, bottom: R.dimen.dp14),
                                  child: Text(
                                    item.description,
                                    style: TextStyle(
                                        fontSize: R.dimen.sp11,
                                        color: R.color.ff888888),
                                  ))
                            ],
                          ),
                          Spacer(),
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              Text.rich(TextSpan(
                                  text:
                                      "${item.expense ? '-' : '+'}${item.amount}",
                                  style: TextStyle(
                                      fontSize: R.dimen.sp14,
                                      fontWeight: FontWeight.w600,
                                      color: R.color.ffff534b),
                                  children: [
                                    TextSpan(
                                        text: "${item.unit}",
                                        style: TextStyle(
                                            fontSize: R.dimen.sp9,
                                            color: R.color.ff333333))
                                  ])),
                              Container(
                                  margin: EdgeInsets.only(
                                      top: R.dimen.dp12, bottom: R.dimen.dp14),
                                  child: Text(
                                    item.status,
                                    style: TextStyle(
                                        fontSize: R.dimen.sp11,
                                        color: R.color.ff888888),
                                  ))
                            ],
                          )
                        ],
                      ),
                    );
                  }),
            )
          ],
        ));
  }
}
